<template>
    <div class="back">
        <div class="container">
            <div class="form-table">
                <h3>股票筛选系统</h3>
                <input type="text" placeholder="请输入账号" v-model="username" /><br>
                <input type="password" placeholder="请输入密码" v-model="password"/><br>
                <p v-if="isRight" style="color: red">账号或密码错误</p>
                <button @click="login">登录</button>
            </div>
        </div>
    </div>
</template>

<script setup>
import {ref} from "vue";
import {useTokenStore} from "@/store/index.js"
import router from "@/router/index.js";

const username = ref('');
const password = ref('');
const isRight = ref(false);
const login = () => {
    const store = useTokenStore()
    const user = {
        username : username.value,
        password : password.value
    };
    let isLogin = store.login(user);
    if (isLogin){
        router.push('/')
    }else {
        isRight.value = true;
    }
}
</script>

<style scoped>
.back{
    display: flex;
    justify-content: center;
    background-image: url("/login-background.jpg");
    background-size: cover;
    background-color: #848484;
    height: 100vh;
    width: 100vw;
}
.container{
    position: relative;
    margin-top: 5%;
    width: 400px;
    height: 400px;
    background-color: #fff;
    border-radius: 6px;
    padding: 25px 25px 5px 25px;
}
.form-table h3{
    margin: 0px auto 30px auto;
    text-align: center;
    color: #707070;
    font-size: 20px;
}
.form-table input{
    margin-bottom: 30px;
    border: 1px solid #d9d9d9;
    outline: none;
    box-shadow: 0 0 0 1px rgba(141, 187, 230, 0.2);
    border-radius: 6px;
    height: 38px;
    width: 100%;
    padding: 25px;
    font-size: 18px;
}

.form-table button{
    position: absolute;
    border-radius: 6px;
    bottom: 70px;
    width: 80%;
    left: 40px;
    height: 50px;
    background: #1890ff;
    border: 1px solid transparent;
    color: #FFFFFF;
    font-size: 20px;
    margin-top: 20px;
    transition: all 0.3s;
}
.form-table button:hover {
    border-color: #eeeeee;
    transform: translateY(2px);
}

.form-table button:active {
    border-color: #eeeeee;
    transform: translateY(4px);
}
</style>
